//package com.hivision.controller.Energy;
//
//import com.hivision.alimqttapi.entity.TechnicalAttribute;
//import com.hivision.iot.api.AliReqClient;
//import com.hivision.iot.dto.AttributeValueRequestDTO;
//import com.hivision.mapper.TechnicalAttributeMapper;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.math.BigDecimal;
//import java.time.ZoneId;
//import java.time.ZonedDateTime;
//import java.time.format.DateTimeFormatter;
//import java.util.Arrays;
//import java.util.List;
//import java.util.Random;
//
//@RequestMapping("/WaterRo1")
//@RestController
//public class WaterRo1 {
//
//    @Autowired
//    private AliReqClient reqClient;
//    @Autowired
//    TechnicalAttributeMapper technicalAttributeMapper;
//
//    List<String>list = Arrays.asList("RO1_water1","RO1_water2","RO1_water3","RO1_water4","RO1_water5","RO1_water6","RO1_water7","RO1_water8","RO1_water9","RO1_water10","RO1_water11","RO1_water12","RO1_water13","RO1_water14","RO1_water15","RO1_water16","RO1_water17","RO1_water18","RO1_water19","RO1_water20","RO1_water21","RO1_water22","RO1_water23","RO1_water24","RO1_water25","RO1_water26","RO1_water27");
//
//    @Scheduled(cron="0 */1 * * * ?")
//    @GetMapping("write")
//    public void writeValue(){
//        for (String s : list) {
//
//            // 创建 Random 类的一个实例
//            Random random = new Random();
//            // 生成一个0到10之间的随机整数
//            int randomNumber = random.nextInt(11);
//
//            // 获取当前系统的日期时间，考虑到时区
//            ZonedDateTime now = ZonedDateTime.now(ZoneId.of("Asia/Shanghai"));
//            // 创建一个日期时间格式器，匹配所需的格式
//            DateTimeFormatter formatter = DateTimeFormatter.ISO_ZONED_DATE_TIME;
//            // 格式化当前日期时间为字符串
//            String formattedNow = now.format(formatter);
//            TechnicalAttribute technicalAttribute1 = new TechnicalAttribute();
//            technicalAttribute1.setAttributeGroupName(s);
//            technicalAttribute1.setAttributeCode("RO_TF");
//            BigDecimal randomFloat = technicalAttributeMapper.selectTechnicalAttributeList(technicalAttribute1).add(new BigDecimal("0.1"));
//            AttributeValueRequestDTO attributeValueRequestDTO = new AttributeValueRequestDTO();
//            attributeValueRequestDTO.setAssetCode(s);
//            attributeValueRequestDTO.setAttributeCode("RO_TF");
//            attributeValueRequestDTO.setValue(String.valueOf(randomFloat));
//            reqClient.patchAttributeValue(attributeValueRequestDTO);
//            TechnicalAttribute technicalAttribute=new TechnicalAttribute();
//            technicalAttribute.setWritable("t");
//            technicalAttribute.setMeasureUni("无");
//            technicalAttribute.setMinValue("min无");
//            technicalAttribute.setMaxValueNew("max无");
//            technicalAttribute.setAssetCode("WaterRo1");
//            technicalAttribute.setAttributeName("累计流量");
//            technicalAttribute.setDataTypeNew("Double");
//            technicalAttribute.setAttributeGroupName(s);
//            technicalAttribute.setAttributeCode("RO_TF");
//            technicalAttribute.setAttributeDescs("无");
//            technicalAttribute.setAttributeGroupDescs("无");
//            technicalAttribute.setEnumValue(String.valueOf(randomFloat));
//            technicalAttribute.setPrecisionNew(36L);
//            technicalAttribute.setCreatedAt(formattedNow);
//            technicalAttribute.setModifiedAt(formattedNow);
//            technicalAttributeMapper.insertTechnicalAttribute(technicalAttribute);
//        }
//    }
//}
